package org.oneblog.data.util;

import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.regex.Pattern;

/**
 * 
 * 静态变量
 * 
 * @author Hunteron
 */
public interface StaticValue {
    
    /**
     * 常用字符串分隔符以及通用常量定义
     */
    public interface SpliteAndChar{
        public static final String PLUS = "+";
        public static final String COMMA = ",";
        public static final String HYPHEN = "-";
        public static final String ASTERISK = "*";
        public static final String UNDERLINE = "_";
        public static final String ONE_BLANK = " ";
        public static final String PERIOD = ".";
        
        public static final String AND = " AND ";
        public static final String OR = " OR ";
        public static final String NOT = " NOT ";
    }

    /**
     * 正则表达式预加载
     */
    public interface Regex {
        public static final Pattern NUMBER = Pattern.compile("[\\d]+");
        public static final Pattern NO_NUMERIC = Pattern.compile("[^-|\\d|\\.|\\d]+");
        public static final Pattern NUMERIC = Pattern.compile("-?\\d+\\.?\\d*");
        public static final Pattern LETTERS = Pattern.compile("\\w+");
        public static final Pattern NUMBER_OR_LETTER = Pattern.compile("[\\d|\\w]+");
        public static final Pattern ID_CARD_LAST = Pattern.compile("(\\d{6})[a-zA-Z]?$");

        public final static Pattern CHINESE_WORD = Pattern.compile("[\u4e00-\u9fa5]+");
        public final static Pattern CONTAIN_CHINESE_WORD = Pattern.compile("\\S*[\u4e00-\u9fa5]+\\S*");

        public final static Pattern CHINESE_WORD_comma_blank_minus = Pattern.compile("[\u4e00-\u9fa5|\\,|\\s|\\-]+");
        public final static Pattern LETTERS_comma_blank_minus = Pattern.compile("[\\w|\\,|\\s|\\-]+");
        public final static Pattern CHINESE_WORD_letter_comma_blank_minus = Pattern.compile("[\u4e00-\u9fa5|\\w|\\,|\\s|\\-]+");


        public static final Pattern ID_SN_PATTERN = Pattern.compile("(\\d+?)\\s+", 0);
        public static final Pattern ID_SN_PATTERN_END = Pattern.compile("(\\d{1,})$", 0);

        public static final Pattern MOBILE_PHONE = Pattern.compile("^((1[3-9]))\\d{9}$");
        public static final Pattern EMAIL = Pattern.compile("^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");

    }

    /**
     * replaceAll的正则表达式
     */
    public interface ReplaceString {
        public static final String INPUT_KEYWORD = "[^a-zA-Z|\u4e00-\u9fa5|\\d|\\-|\\+|\\s|\\@|\\!|\\！|\\.]";
        public static final String DEFAULT_STATIC_KEYWORD = "hunter_on";
        public static final String AUTOKEY_FILTER = "[^a-zA-Z|\u4e00-\u9fa5|\\d|\\-|\\+|\\#]";
        /**
         * 替换关键字中的空格
         */
        public static final String SPECIAL_SPLIT = "#%%#";
    }

    /**
     * 日期格式化字符串定义
     */
    public interface DateFormatString {

        /** yyyy-MM-dd HH:mm:ss */
        public static final String FULL_ON_SECOND_END_SECOND = "yyyy-MM-dd HH:mm:ss";
        /** yyyy-MM-dd 00:00:00 */
        public static final String FULL_ON_DAY_END_SECOND = "yyyy-MM-dd 00:00:00";
        /** yyyy-MM-dd HH:mm */
        public static final String FULL_ON_MINUTE_END_MINUTE = "yyyy-MM-dd HH:mm";
        /** yyyy-MM-dd */
        public static final String FULL_ON_DAY_END_DAY = "yyyy-MM-dd";

        /** yyyyMMdd */
        public static final String SIMPLE_ON_DAY_END_DAY = "yyyyMMdd";
        /** yyyyMMddHH */
        public static final String SIMPLE_ON_HOUR_END_HOUR = "yyyyMMddHH";
        /** yyyyMMddHHmmss */
        public static final String SIMPLE_ON_SECOND_END_SECOND = "yyyyMMddHHmmss";
        /** HHmmss */
        public static final String SIMPLE_STRING_HHmmss = "HHmmss";

        public static final String SIMPLE_YEAR_MONTH = "yyyyMM";
        public static final String SIMPLE_DAY_HH = "dd";
    }

    /**
     * 日期格式化 SimpleDateFormat 定义
     */
    public interface DateFormat {
        /** yyyy-MM-dd HH:mm:ss */
        public static final SimpleDateFormat FULL_ON_SECOND_END_SECOND = new SimpleDateFormat(DateFormatString.FULL_ON_SECOND_END_SECOND);
        /** yyyy-MM-dd 00:00:00 */
        public static final SimpleDateFormat FULL_ON_DAY_END_SECOND = new SimpleDateFormat(DateFormatString.FULL_ON_DAY_END_SECOND);
        /** yyyy-MM-dd HH:mm */
        public static final SimpleDateFormat FULL_ON_MINUTE_END_MINUTE = new SimpleDateFormat(DateFormatString.FULL_ON_MINUTE_END_MINUTE);
        /** yyyy-MM-dd */
        public static final SimpleDateFormat FULL_ON_DAY_END_DAY = new SimpleDateFormat(DateFormatString.FULL_ON_DAY_END_DAY);

        /** yyyyMMdd */
        public static final SimpleDateFormat SIMPLE_ON_DAY_END_DAY = new SimpleDateFormat(DateFormatString.SIMPLE_ON_DAY_END_DAY);
        /** yyyyMMddHHmmss */
        public static final SimpleDateFormat SIMPLE_ON_SECOND_END_SECOND = new SimpleDateFormat(DateFormatString.SIMPLE_ON_SECOND_END_SECOND);

        /** HHmmss */
        public static final SimpleDateFormat SIMPLE_STRING_HHmmss = new SimpleDateFormat(DateFormatString.SIMPLE_STRING_HHmmss);


        public static final SimpleDateFormat SIMPLE_YEAR_MONTH = new SimpleDateFormat(DateFormatString.SIMPLE_YEAR_MONTH);
        
        public static final SimpleDateFormat SIMPLE_DAY_HH = new SimpleDateFormat(DateFormatString.SIMPLE_DAY_HH);
    }

    /**
     * Integer升序
     */
    public static IntegerSort INTEGER_COMPARATOR_ASC = new IntegerSort();
}

class IntegerSort implements Comparator<Integer> {

    public int compare(Integer o1, Integer o2) {
        if (o1 == o2) {
            return 0;
        } else if (o1 > o2) {
            return 1;
        } else {
            return -1;
        }
    }
}
